// 模拟提供上传插件

window.external.upload = function(state) {
    console.log(state); // sign、uploading、done、error
}

export default class Plugin {
    constructor() {
        this.timer = null;
        this.dom = document.createElement('embed');
        this.dom.style.display = 'none';
        this.dom.type = 'application/txftn-webkit';
        document.body.appendChild(this.dom);
    }

    sign() {
        console.log('文件开始扫描');
        setTimeout(() => {
            window.external.upload('uploading');
        }, 3000);
    }

    pause() {
        console.log('暂停文件上传');
        clearTimeout(this.timer);
    }

    uploading() {
        console.log('开始文件上传');
        this.timer = setTimeout(() => {
            window.external.upload('done');
        }, 8000);
    }

    del() {
        console.log('删除文件上传');
    }

    done() {
        console.log('文件上传完成');
    }
}
